package main

import (
	"math/rand"
	"time"
	"fmt"
)

func main() {
	// 切片作为参数时，是引用传递
	// 切片变量就是一个地址
	s := make([]int, 10)
	random(s)
	fmt.Println(s)

	sort(s)
	fmt.Println(s)
}

func random(s []int) {
	rand.Seed(time.Now().Unix())
	len := len(s)
	for i := 0; i < len; i++ {
		s[i] = rand.Intn(100)
	}
}

func sort(s []int) {
	len := len(s)
	for i := 0; i < len; i++ {
		for j := 0; j < len-i-1; j++ {
			if s[j] < s[j+1] {
				s[j], s[j+1] = s[j+1], s[j]
			}
		}
	}

}
